package com.idcf.boathouse.product.models;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.idcf.boathouse.product.untils.JsonUtils;
import com.idcf.boathouse.product.vo.OrderItemsCreateVo;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @Author Leon.xie
 * @Date 2021/6/27
 * @Description
 */

@Data
@TableName(value = "orders")
public class TravelOrder {

    @TableId(value = "id", type = IdType.AUTO)
    private long id;

    @TableField(value = "order_no", insertStrategy = FieldStrategy.DEFAULT)
    private String orderNo;

    @TableField(value = "user_id", insertStrategy = FieldStrategy.DEFAULT)
    private long userId;

    @JsonIgnore
    @TableField(value = "consumer_date_json", insertStrategy = FieldStrategy.DEFAULT)
    private String consumerDateJson;

    @TableField(value = "amount", insertStrategy = FieldStrategy.DEFAULT)
    private BigDecimal amount;

    @TableField(value = "order_status", insertStrategy = FieldStrategy.DEFAULT)
    private int orderStatus;

    @TableField(value = "valid_time", insertStrategy = FieldStrategy.DEFAULT)
    private Date validTime;

    @TableField(value = "pay_status", insertStrategy = FieldStrategy.DEFAULT)
    private int payStatus;

    @TableField(value = "create_time", insertStrategy = FieldStrategy.DEFAULT)
    private Date createTime;

    @TableField(value = "update_time", insertStrategy = FieldStrategy.DEFAULT)
    private Date updateTime;

    private List<OrderItemsCreateVo> consumerDate;

    public void setConsumerDateJson(String consumerDateJson){
        this.consumerDateJson = consumerDateJson;
        this.consumerDate = JsonUtils.parse(consumerDateJson,List.class);
    }
}
